package com.wizo.csb.generator;

/**
 * Generates a sequence of integers 0, 1, ...
 * @author ywu70
 *
 */
public class CounterGenerator extends IntegerGenerator{
	
	int counter;
	
	/**
	 * Create a counter that starts as a countStart
	 */
	public CounterGenerator(int countStart){
		counter = countStart;
		setLastInt(countStart-1);
	}
	
	/**
	 * Return the next value as an int.
	 */
	public synchronized int nextInteger(){
		int lastInt = counter;
		setLastInt(lastInt);
		counter++;
		return lastInt;
	}
	
}
